import { fileURLToPath, URL } from "node:url";
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import cesium from "vite-plugin-cesium";
import legacy from '@vitejs/plugin-legacy'
// https://vite.dev/config/
export default defineConfig({
  plugins: [vue(), cesium(),legacy({
    targets: ['chrome >= 74'], // 明确指定Chrome 74为目标
    modernPolyfills: true,      // 为现代浏览器也提供必要的polyfill
    additionalLegacyPolyfills: ['regenerator-runtime/runtime'] // 添加额外polyfill
  })],
  build: {
    target: 'es2015' // 构建目标设置为ES2015
  },
  optimizeDeps: {
    exclude: ['virtual-webgl'] // 避免 Vite 预构建 virtual-webgl
  },
  server: {
    proxy: {
      '/api': {
        // target: 'http://192.168.124.102:8090',
        target: 'http://47.110.51.175:8090',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      }
    }
  },
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url)),
    },
  },
});
